package com.gxa.feign.controller;

import com.gxa.feign.interfaces.ServiceFeignByShow;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author LENOVO
 */
@RestController
public class ShowController {

    private ServiceFeignByShow serviceFeignByShow;

    @Resource
    public void setServiceFeignByShow(ServiceFeignByShow serviceFeignByShow) {
        this.serviceFeignByShow = serviceFeignByShow;
    }

    /**
     * 这里类似于ribbon，提供一个对外访问的接口地址，
     * 然后根据ServiceFeignByShow接口来决定调用哪一个子模块服务和哪一个接口地址
     *
     * @param name
     * @return
     */
    @RequestMapping(value = "/show", method = RequestMethod.GET,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Map show(String name) {
        System.out.println("name=" + name);
        return serviceFeignByShow.selectClient(name);
    }
}

